/**
 * 
 */
package com.tw.trips.dao;

import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.neo4j.support.Neo4jTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.test.context.ContextConfiguration;

import com.tw.trips.domain.Comment;
import com.tw.trips.domain.ItHelps;
import com.tw.trips.domain.Traveller;
import com.tw.trips.domain.Update;
import com.tw.trips.repository.TravellerRepository;

/**
 * @author M1005264
 * 
 */
@Repository
@ContextConfiguration(locations = { "classpath:applicationContext.xml" })
public class UpdatePostDAO {

	@Autowired
	private Neo4jTemplate template;

	@Autowired
	private TravellerRepository travellerRepository;

	public Set<Update> getUpdatesByTraveller(Traveller traveller) {
		return travellerRepository.findByEmailID(traveller.getEmailID())
				.getUpdates();
	}

	public Update saveOrUpdate(Update update) {
		return template.save(update);
	}

	public Comment saveOrUpdate(Comment comment) {
		return template.save(comment);
	}

	public ItHelps saveOrUpdate(ItHelps itHelps) {
		return template.save(itHelps);
	}

}
